//
//  ViewController.m
//  UILable程序
//
//  Created by mir_yan on 2018/10/2.
//  Copyright © 2018年 hakeem. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 打印所有字体 Bradley Hand
//    NSArray* family = [UIFont familyNames];
//    NSLog(@"family:%@", family);

    NSString* expString = @"匆匆那年 一段凄美的爱情";
    
    
    NSMutableAttributedString* muAttriString =
        [[NSMutableAttributedString alloc] initWithString:expString];
    NSRange rage = [expString rangeOfString:@"匆匆那年"];
    
    //手动设置属性变化
    [muAttriString addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Bradley Hand" size:30] range:rage];
    
    // 获取屏幕宽度
//    CGFloat GCwidth = [UIScreen mainScreen].bounds.size.width;
    //self.view 当前视图
//    CGFloat GCwidth = CGRectGetWidth(self.view.frame);
    
    UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(20, 150, CGRectGetWidth(self.view.frame) - 40, 60)];
    // 设置
    label.attributedText = muAttriString;
    // 设置大小
    NSDictionary* dect = @{NSFontAttributeName:[UIFont systemFontOfSize:30]};
    CGSize labelSize = [expString sizeWithAttributes:dect];
    label.bounds = (CGRect){CGPointZero, labelSize};
    // 设置屏幕中间
//    [label setTextAlignment:NSTextAlignmentCenter];
//    label.center = self.view.center;

    label.frame = CGRectMake(10, 100, labelSize.width, labelSize.height);
    label.center = self.view.center;
    
    // 设置标签的内容
    // 不缺 变...
    label.text = expString;
    //设置字体的大小
//    [label setFont:[UIFont systemFontOfSize:30]];
    // 设置字体颜色
    [label setTextColor:[UIColor yellowColor]];
    // 设置对其
    [label setTextAlignment:NSTextAlignmentCenter];
    // 阴影
    label.shadowColor = [UIColor redColor];
    // 阴影大小
    label.shadowOffset = CGSizeMake(-5, -5);
    // 设置断句
    label.lineBreakMode = NSLineBreakByTruncatingMiddle;
    // 设置行数 0显示任意行
    label.numberOfLines = 0;
    // 高亮状态颜色
    label.highlightedTextColor = [UIColor brownColor];
    // 设置高亮状态
    label.highlighted = YES;
    // 字体自适应label宽度 UIFont 自动失效
    label.adjustsFontSizeToFitWidth = YES;
    // 设置最小缩放比例
    label.minimumScaleFactor = 0.7;
    // 设置禁用状态
//    label.enabled = NO;
    // label 背景设置
    [label setBackgroundColor:[UIColor orangeColor]];
    
    
    // label自适应
    //    [label sizeToFit];
//    定制限宽
//    CGSize CGlabelSize = [label sizeThatFits:CGSizeMake(CGRectGetWidth(self.view.frame) - 40, MAXFLOAT)];
//    CGRect frme = label.frame;
//    frme.size = CGlabelSize;
//    label.frame = frme;
    
    [self.view addSubview:label];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
